package edu.kit.aifb.ruleintegrator.bayes.network;

import java.util.HashMap;
import java.util.Map;

import edu.kit.aifb.ruleintegrator.util.Util;

public class RuleFactor extends Factor {
	
	private double m_w0=0.0;
	private Map<RandomVariable,Double> m_weights;
//	private final RuleVariable m_rule;
	public RuleFactor(){
		this.m_weights=new HashMap<RandomVariable, Double>();
//		this.m_rule=rule;
	
	}
	
	public double compute(Map<RandomVariable,Integer> assignment){
		double total=m_w0;
		for(RandomVariable var:assignment.keySet()){
			total+=m_weights.get(var)*assignment.get(var);
		}
		
				
		return Util.sigmoid(total);
	}
	
	
	public Map<RandomVariable, Double> getWeights(){
		return this.m_weights;
	}
	
	public double getBaseWeight(){
		return this.m_w0;
	}
	
	public void setBaseWeight(double w0){
		this.m_w0=w0;
	}
}
